package com.example.service;

import com.example.entity.VideoComments;
import com.example.entity.VideoHistory;
import com.example.mapper.VideoHistoryMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*历史记录视频业务处理
 */
@Service
public class VideoHistoryService {

    @Resource
    private VideoHistoryMapper videoHistoryMapper;

    public void add(VideoHistory videoHistory) {
        videoHistoryMapper.insert(videoHistory);
    }

    public void deleteById(Integer id) {
        videoHistoryMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(VideoHistory videoHistory) {
        videoHistoryMapper.updateById(videoHistory);
    }

    public VideoHistory selectById(Integer id) {
        return videoHistoryMapper.selectById(id);
    }

    public List<VideoHistory> selectAll(VideoHistory videoHistory) {
        return videoHistoryMapper.selectAll(videoHistory);
    }

    public PageInfo<VideoHistory> selectPage(VideoHistory videoHistory, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<VideoHistory> videoHistoryList = videoHistoryMapper.selectAll(videoHistory);
        return PageInfo.of(videoHistoryList);
    }
}
